/*********************************************
 * Student    : Teodoro Cipresso
 * Course     : CS286
 * Professor  : Vidya Setlur
 * Assignment : Term Project (BlueTanks)
 *********************************************/
package edu.sjsu.cs286.teodoro.cipresso.playfield;

import java.io.IOException;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.TiledLayer;

/**
 * This method implements creation of the TiledLayers for the playfield. The
 * methods are compoentized here as static methods
 * 
 * @author Teodoro Cipresso
 */
public class BlueTankTerrain implements IBlueTankTerrain {

	/**
	 * Draw the the passable terrain segments using a static map indicating the
	 * layout and segments used. The maze is implemented via TiledLayer.
	 */
	public static TiledLayer createPassableTerrain() throws IOException {
		Image image = Image.createImage(TERRAIN_IMG_SRC);
		TiledLayer tiledLayer = new TiledLayer(9, 14, image, 20, 20);
		//
		int col = 0, row = 0;
		for (int i = 0; i < PASSABLE_TERRAIN_MAP.length; i++) {
			col = i % 9;
			if (col == 0 && i > 0)
				row++;
			tiledLayer.setCell(col, row, PASSABLE_TERRAIN_MAP[i]);
		}
		//
		return tiledLayer;
	} // createPassableTerrain()

	/**
	 * Draw the the impassable terrain segments using a static map indicating
	 * the layout and segments used. The maze is implemented via TiledLayer.
	 */
	public static TiledLayer createImpassableTerrain() throws IOException {
		Image image = Image.createImage(TERRAIN_IMG_SRC);
		TiledLayer tiledLayer = new TiledLayer(9, 14, image, 20, 20);
		//
		int col = 0, row = 0;
		for (int i = 0; i < IMPASSABLE_TERRAIN_MAP.length; i++) {
			col = i % 9;
			if (col == 0 && i > 0)
				row++;
			tiledLayer.setCell(col, row, IMPASSABLE_TERRAIN_MAP[i]);
		}
		//
		return tiledLayer;
	} // createImpassableTerrain()

} // BlueTankTerrain()
